<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
    <script type="text/javascript" src="js/jquery.js"></script>
	<style type="text/css">
		span{
			color:red;
		}
	</style>
  </head>
  
  <body>
	<h3>系统登录</h3>
	<%
	String code = request.getParameter("code");
	if("10001".equals(code)){
	%>	
	<div style = color:red>用户名或密码错误</div>
	<%}else if("10002".equals(code)){
	%>
	<div style = color:red>请先登录</div>
	<%}%>
  	<form action="login.jsp" id="myform" method="post">
	username：<input type="text" name="username"/><span id="name_error"></span><br>
	password：<input type="password" name="password"/><span id="pwd_error"></span><br>
	<input type="button" value="Login" id="btn">  		
  	</form>
  	
  	<script type="text/javascript">
  		$(document).ready(function(){
  			$("#btn").click(function(){
  				var name = $("input[name='username']").val();
  				var pwd = $("input[name='password']").val();
  				if(name.trim()==""){
  					$("#name_error").html("请输入用户名");
  					return;
  				}
  				if(pwd==""){
  					$("#pwd_error").html("请输入密码");
  					return;
  				}
  				$("#myform").submit();
  			});
  		});
  	</script>
  </body>
</html>
